<?php
include('class/class_connect.php');
include('class/class_page.php');
include('class/class_comments.php');
include('class/class_address.php');
include('class/class_workdays.php');
include('class/class_rating.php');
include('class/abstract/class_mainObjectInfo.php');
include('class/city_rus.php');
include('class/class_checkGetData.php');
foreach($_GET as $key=>$val)
{
	$_GET[$key]=checkGetData::safetyCheck($val);
}
if(!($_GET['obj']=='firms' || $_GET['obj']=='malls'))
	checkGetData::error();
$aCheck=new checkGetData(substr($_GET['obj'], 0, 1));
$aCheck->checkCity($_GET['city']);
$aCheck->checkTableId($_GET['city'], $_GET['id']);

$aComment=new comments(substr($_GET['obj'], 0, 1), $_GET['city'], $_GET['id']);
$aComment->addComment();
session_start();
$aConnect=new connect(substr($_GET['obj'], 0, 1));
$row=mysql_fetch_array($aConnect->select_all($_GET['city'], "WHERE id='".$_GET['id']."'"));

class aFirmPage extends page
{
	var $row=array();
	var $cityRus;
	function __construct($row)
	{		$this->row=$row;
		$this->cityRus=new city_rus_class();
		parent::__construct();
	}
	function title()
	{
		echo 'Отзывы '.$this->row['name'].' '.$this->cityRus->city_rus_im($_GET['city']);
	}
	function maincontent()
	{
		echo ('
		<div class="photoFrame">
		</div>
		<div class="route">
			');
			if($this->row['division'])
			{
			echo ('
			<div class="routeEl">
				<a href="division.php?city='.$_GET['city'].'&division='.$this->row['division'].'">'.$this->row['division'].'</a>
			</div>
			<div class="routeEl">
				<a href="'.$_GET['obj'].'_list.php?city='.$_GET['city'].'&subdiv='.$this->row['subdiv'].'">'.$this->row['subdiv'].'</a>
			</div>
				');
			}
			else
			{				echo ('
			<div class="routeEl">
				<a href="malls_list.php?city='.$_GET['city'].'">Торговые центры</a>
			</div>
				');			}
		echo ('
			<div class="routeEl">
				<a href="'.$_GET['obj'].'.php?city='.$_GET['city'].'&id='.$_GET['id'].'">'.$this->row['name'].'</a>
			</div>
			<div class="routeEl">
				Отзывы
			</div>
		</div>
		');
		$aFirmInfo=new aFirmInfo($this->row);
		$aComment=new comments(substr($_GET['obj'],0 ,1), $_GET['city'], $_GET['id']);
		$comConnect=new connect(substr($_GET['obj'], 0, 1).'c');
		$comNum=mysql_num_rows(connect::select_all($_GET['city'], "WHERE ".substr($_GET['obj'], 0, 1)."_id='".$_GET['id']."'"));
		if($comNum==0)$comsName="Будьте первым";
		else $comsName="Все отзывы (".$comNum.")";
		echo ('<center><h4>'.$comsName.'</h4></center>');
		$aComment->showComments();
		$aComment->commentForm($_SESSION['login']);
	}
}




class aFirmInfo extends mainObjectInfo
{
	var $row;
	function __construct($row=array())
	{
		$this->row=$row;
		parent::__construct();
	}
	function showPic()
	{
		echo ('
		<img src="pictures/'.$_GET['obj'].'pics/'.$_GET['city'].'/'.$this->row['id'].'.jpg" title="'.$this->name.'">
		');
	}
	function showAddress()
	{
		$address=new address();
		if($_GET['obj']=='firms')
			$addressString=$this->row['address'];
		else if($_GET['obj']=='malls')
		{			$streetBuildingArr=explode(',', $this->row['address']);			$addressString=$streetBuildingArr[0].'^'.$streetBuildingArr[1].'^'.$this->row['phone'].'^^'.$this->row['workdays'];		}
		$address->showSeveralAddresses($addressString, $this->row['link']);
	}
	function showshort()
	{
		echo $this->row['short'];
	}
	function showName()
	{
		echo $this->row['name'];
	}
}
$aPage=new aFirmPage($row);

?>